package com.hhc.controller;

import com.hhc.dto.RestResult;
import com.hhc.dto.TeacherCourseAssignmentDTO;
import com.hhc.query.CourseTeacherQuery;
import com.hhc.query.TeacherCourseAssignmentQuery;
import com.hhc.service.TeacherCourseAssignmentService;
import java.util.List;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

/**
 * <p>
 *   教师授课任务控制层接口
 * </p>
 * @author pc
 */
@Slf4j
@RestController
@RequestMapping("/teacher-course-assignment")
@Validated
public class TeacherCourseAssignmentController {
    @Autowired
    private TeacherCourseAssignmentService teacherCourseAssignmentService;

    @PostMapping("/add")
    public RestResult<TeacherCourseAssignmentDTO> addTeacherCourseAssignment(@Valid @RequestBody TeacherCourseAssignmentDTO assignmentDTO) {
        return teacherCourseAssignmentService.addTeacherCourseAssignment(assignmentDTO);
    }

    @DeleteMapping("/delete/{id}")
    public RestResult<Void> deleteTeacherCourseAssignment(@PathVariable Long id) {
        return teacherCourseAssignmentService.deleteTeacherCourseAssignment(id);
    }

    @PutMapping("/update")
    public RestResult<TeacherCourseAssignmentDTO> updateTeacherCourseAssignment(@Valid @RequestBody TeacherCourseAssignmentDTO assignmentDTO) {
        return teacherCourseAssignmentService.updateTeacherCourseAssignment(assignmentDTO);
    }

    @GetMapping("/list")
    public RestResult<List<TeacherCourseAssignmentDTO>> getTeacherCourseAssignmentList(@Valid TeacherCourseAssignmentQuery query) {
        return teacherCourseAssignmentService.getTeacherCourseAssignmentList(query);
    }

    @GetMapping("/course-teachers")
    public RestResult<List<TeacherCourseAssignmentDTO>> getCourseTeachers(@Valid CourseTeacherQuery query) {
        return teacherCourseAssignmentService.getCourseTeachers(query);
    }
}
